<template>
  {{$lens := .table.Columns|len}}
  {{$businessName := .table.BusinessName | CaseCamelLower}}
  <div class="app-container">
    <div class="m-condition">
      <crud-search/>
      <div class="crud-header">
        <div/>
        <crud-operation/>
      </div>
    </div>
    <crud-grids field="grids"/>
    <crud-pagination field="page"/>
    <!-- 添加或修改{{.table.FunctionName}}对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :close-on-click-modal="false">
      <crud-form field="form"/>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  {{$plugin:=""}}
  {{if ContainsI $.table.PackageName "plugins"}}
    {{$plugin = "plugins/"}}
  {{end}}
  import * as _API from "./api";
  import CRUD, {crud, presenter, grids} from "@CRUD";
  import {formOptions} from "./options"
  import crudForm from "./form"
  export default {
    name: "{{.table.ClassName}}",
    cruds() {
      return CRUD({
        title: "{{.table.ClassName}}",
        crudMethod: _API,
        queryInit: true,
        gridsEdit: true,
        optShow: {
          toAdd: true,
          toEdit: true,
          toRefresh: true,
          toSave: false,
          toDel: true
        },
        form: formOptions('code'),
        defaultParams: {
          pageNum: 1,
          pageSize: 10,{{range $index, $column := .table.Columns}}{{if eq $column.IsQuery "1"}}
              {{$column.JavaField}}: undefined{{if ne $lens $index}},{{end}}{{end}}{{end}}
        },
        queryCondition:[{{range $index, $column := .table.Columns}}
          {
            'label': '{{$column.ColumnComment}}',
            'value': '{{$column.JavaField}}'
          },
        {{end}}]
      });
    },
    components: {crudForm}
  };
</script>